frame reset 
global results  "/Users/myresults"

* Dataset
use myfile.dta, clear 
rename classorder region 
rename class regionname
sort region year 
	* 1. Variable labels 
label def region_l 0 "US" 1 "Northeast" 2 "Midwest" 3 "South" 4 "West" 5 "Rural" 6 "Urban"
label val region region_l
label var suicides_10_19 "Deaths: Suicide"
label var suicides_10_19_m "Deaths: Suicide Male"
label var suicides_10_19_f "Deaths: Suicide Female"
label var any_si "ED: Suicidal Ideation"
label var any_si_m  "ED: Suicidal Ideation Male"
label var any_si_f "ED: Suicidal Ideation Female"
label var any_selfharm  "ED: Self-harm"
label var any_selfharm_m "ED: Self-harm Male"
label var any_selfharm_f "ED: Self-harm Female" 
label var any_mental "ED: Any mental health"
label var any_mental_m "ED: Any mental health  Male"
label var any_mental_f "ED: Any mental health  Female"
label var any_mood "ED: Any mood" 
label var any_mood_m "ED: Any mood Male"
label var any_mood_f "ED: Any mood Female"
label var any_anxiety "ED: Any anxiety"
label var any_anxiety_m "ED: Any anxiety Male"
label var any_anxiety_f "ED: Any anxiety  Female"
label var any_moodanx "ED: Any Mood/anxiety"
label var any_moodanx_m "ED: Any Mood/anxiety Male"
label var any_moodanx_f "ED: Any Mood/anxiety Female"
label var any_othermental "ED: Any other mental health"
label var any_othermental_m "ED: Any other mental health  Male"
label var any_othermental_f "ED: Any other mental health  Female"
label var prim_mental "ED: Primary mental health"
label var prim_mood "ED: Primary mood"
label var prim_anxiety "ED: Primary anxiety"
label var prim_moodanx "ED: Primary Mood/anxiety"
label var prim_othermental "ED: Primary Other mental health"
label var any_und "ED: Any undetermined intent"
label var prim_mental_m "ED: Primary mental health  Male"
label var prim_mental_f "ED: Primary mental health Female"
label var prim_mood_m "ED: Primary mood Male"
label var prim_mood_f "ED: Primary mood Female"
label var prim_anxiety_m "ED:  Primary anxiety Male"
label var prim_anxiety_f "ED:  Primary anxiety Female"
label var prim_moodanx_m "ED:  Primary Mood/anxiety Male"
label var prim_moodanx_f "ED:  Primary Mood/anxiety Female"
label var prim_othermental_m "ED: Primary Other mental health  Male"
label var prim_othermental_f "ED: Primary Other mental health Female"
label var sec_mental "ED: Secondary mental health"
label var sec_mental_m "ED: Secondary mental health Male"
label var sec_mental_f "ED: Secondary mental health Female"
label var behavior_m "ED: Suicidal Behaviors Male"
label var behavior_f "ED: Suicidal Behaviors Female"
label var behavior "ED: Suicidal Behaviors"

	* 2. Projected trends 
	* 2.1 Undetermined intent versus self-harm related ED visits 
gen any_selfharm_c=any_selfharm if  region==0
gen any_und_c=any_und if  region==0
gen any_selfharm_und=any_selfharm + any_und
gen share_selfharm=any_selfharm/(any_selfharm_und)
sum share_selfharm if year==2015 & region==0
replace any_selfharm_c=r(mean)*any_selfharm_und if year>2015 &  region==0
replace  any_und_c=(1-r(mean))*any_selfharm_und if year>2015 &  region==0

label var any_selfharm_c  "ED: Self-harm Corrected"
label var any_und_c "ED: Any undetermined intent Corrected"

	*2.2 Trends using the 2006 ratio of ED visits in each category 
foreach var in any_si any_moodanx any_selfharm  behavior {
	gen temp=`var'/suicides_10_19 if year==2006 & region==0
	egen share`var'=max(temp), by(region)
	drop temp
	
	gen `var'2= suicides_10_19*share`var'	
}

	*3. Growth rates relative to 2006. 
foreach var in suicides_10_19 suicides_10_19_m suicides_10_19_f any_si any_si_m any_si_f any_selfharm any_selfharm_m any_selfharm_f any_mental any_mental_m any_mental_f any_mood any_mood_m any_mood_f any_anxiety any_anxiety_m any_anxiety_f any_moodanx any_moodanx_m any_moodanx_f any_othermental any_othermental_m any_othermental_f prim_mental prim_mood prim_anxiety prim_moodanx prim_othermental any_und sec_mental prim_mental_m prim_mental_f prim_mood_m prim_mood_f prim_anxiety_m prim_anxiety_f prim_moodanx_m prim_moodanx_f prim_othermental_m prim_othermental_f behavior_m behavior_f behavior sec_mental_m sec_mental_f any_selfharm_poison any_unintentional_poison any_und_poison any_selfharm_cutting any_unintentional_cutting any_und_cutting any_selfharm_c any_und_c any_selfharm_cdc any_si2 any_moodanx2 any_selfharm2 behavior2 {
	gen temp=`var' if year==2006
	egen `var'06=max(temp), by(region)
	drop temp 
	gen i`var'=`var'/`var'06
	label var i`var' "Index: change relative to 2006"
	drop `var'06
}

	*4. Rates per 100,000 teens 
foreach var in any_si suicides_10_19 any_selfharm any_mental  any_mood  any_anxiety  any_moodanx  any_othermental sec_mental  prim_mental prim_mood prim_anxiety prim_moodanx prim_othermental  behavior any_selfharm_cdc {
	gen rr_`var'=100000*(`var'/pop)
	gen rr_`var'_f=100000*(`var'_f/popfemale)
	gen rr_`var'_m=100000*(`var'_f/popmale)	
	label var rr_`var' "Rate per 100K teens"
	label var rr_`var'_f "Rate per 100K Female teens"	
	label var rr_`var'_m "Rate per 100K Male teens"
}
foreach var in any_und any_selfharm_poison any_unintentional_poison any_und_poison any_selfharm_cutting any_unintentional_cutting any_und_cutting any_selfharm_c any_und_c any_si2 any_moodanx2 any_selfharm2 behavior2 {
	gen rr_`var'=100000*(`var'/pop)
	label var rr_`var' "Rate per 100K teens"
}

	*5. Create a new year variable to display years more clearly 
gen year2=. 
local n=0
forvalues i=0/6 {
	local n=0
	forvalues x=2006(3)2051 {
		local n=`n'+1
		replace year2=`x' if region==`i' & year==2005+`n' & year<=2021
	}
}

	*5.1 Labels 	
label define y 2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021"
label values year2 y

**************************
* MAIN 
*************************

*************
* Figure 2: ED visits involving primary and secondary mental health diagnoses.
*************
	* Labels 
label var iany_mental "ED: Any Mental Health Disorder" 
label var isec_mental "ED: Secondary is Mental Health Disorder" 
label var iprim_mental "ED: Primary is Mental Health Disorder"

	* Data for last year in our sample period
local n=0
foreach var in iany_mental isec_mental iprim_mental {
	local n=`n'+1
	sum `var' if region==0 & year==2021
	local a`n': display %9.2f r(mean)
	local b`n'=`a`n''+ 0.2
}	
local bb3=`b3'-0.3
twoway (connected iany_mental year2 if region==0, msymbol(circle) mcolor(black) lcolor(black) msize(medium)) ///
(connected isec_mental year2 if region==0, msymbol(square) mcolor(black) lcolor(black) msize(medium) lpattern(dash)) ///
(connected iprim_mental year2 if region==0, msymbol(square_hollow) mcolor(black) lcolor(black) msize(medium)), ///
ylabel(0.8(0.2)1.8, nogrid format(%8.1f) labsize(medium)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("Index (base=2006)", size(medsmall)) xtitle("")    legend( region(lcolor(none)) size(medium) cols(1) position(6)) text(`b1' 2048 "`a1'" , place(e) size(medsmall)) text(`b2' 2048 "`a2'" , place(e) size(medsmall)) text(`b2' 2048 "`a2'" , place(e) size(medsmall)) text(`bb3' 2048 "`a3'" , place(e) size(medsmall))

graph save "Graph" ${results}2a.gph, replace
graph export ${results}2a.pdf, as(pdf) name("Graph") replace
graph close

label var rr_any_mental "ED: Any Mental Health Disorder" 
label var rr_sec_mental "ED: Secondary is Mental Health Disorder" 
label var rr_prim_mental "ED: Primary is Mental Health Disorder" 
local n=0
foreach var in rr_any_mental rr_sec_mental rr_prim_mental {
	local n=`n'+1
	sum `var' if region==0 & year==2021
	local a`n': display %9.0f r(mean)
	local b`n'=`a`n''+ 400
}	
local bb3=`b3'-0.2
twoway (connected rr_any_mental year2 if region==0, msymbol(circle) mcolor(black) lcolor(black) msize(medium)) ///
(connected rr_sec_mental year2 if region==0, msymbol(square) mcolor(black) lcolor(black) msize(medium) lpattern(dash)) ///
(connected rr_prim_mental year2 if region==0, msymbol(square_hollow) mcolor(black) lcolor(black) msize(medium)), ///
ylabel(1000(1000)5000, nogrid format(%8.0f) labsize(medium)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("ED visits per 100,000 Teens", size(medsmall)) xtitle("")    legend( region(lcolor(none)) size(medium) cols(1) position(6)) text(`b1' 2048 "`a1'" , place(e) size(medsmall)) text(`b2' 2048 "`a2'" , place(e) size(medsmall)) text(`bb3' 2048 "`a3'" , place(e) size(medsmall))

graph save "Graph" ${results}2b.gph, replace
graph export ${results}2b.pdf, as(pdf) name("Graph") replace
graph close

*************
* Figure 3: ED visits involving mental health disorders by gender and type of diagnosis 
*************
	* Labels 
label var iany_mental "ED: Any Mental Health Disorder" 
label var iany_moodanx "ED: Any Mood/Anxiety Disorder" 
label var iany_othermental "ED: Any Other Mental Health Disorder" 
label var iany_mental_f "ED: Any Mental Health Disorder" 
label var iany_moodanx_f "ED: Any Mood/Anxiety Disorder" 
label var iany_othermental_f "ED: Any Other Mental Health Disorder" 
label var iany_mental_m "ED: Any Mental Health Disorder" 
label var iany_moodanx_m "ED: Any Mood/Anxiety Disorder" 
label var iany_othermental_m "ED: Any Other Mental Health Disorder"	

	* All 
local n=0
foreach var in iany_mental iany_moodanx iany_othermental {
local n=`n'+1
sum `var' if year==2021  & region==0
local a`n': display %9.2f r(mean)
local b`n'=`a`n''+ 0.1
}	

	* Plot
twoway (connected iany_mental year2 if region==0, msymbol(square_hollow) mcolor(black) lcolor(black) msize(medium) lpattern(dash_dot)) ///
(connected iany_moodanx year2 if region==0, msymbol(circle) mcolor(navy) lcolor(navy) msize(medium)) ///
(connected iany_othermental year2  if region==0, msymbol(circle) mcolor(navy*0.6) lcolor(navy*0.6) msize(medium)) , /// 
 legend( region(lcolor(none)) size(medium) cols(2) position(6)) ylabel(0.8(0.2)2.4, nogrid labsize(medium) format(%8.1f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", labsize(medium) nogrid angle(vertical)) ytitle("Index (base=2006)") xtitle("") ///
text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall))  text(`b3' 2049 "`a3'" , place(e) size(medsmall)) 
	
* Save the figure 
graph save "Graph" ${results}3a.gph, replace
graph export ${results}3a.pdf, as(pdf) name("Graph") replace	
graph close


		* By gender
foreach s in m f {
	* Get data point for the last year. 
	local n=0
	foreach var in iany_mental iany_moodanx iany_othermental {
		local n=`n'+1
		sum `var'_`s' if year==2021  & region==0
		local a`n': display %9.2f r(mean)
		local b`n'=`a`n''+ 0.1
}	
	
	* Plot
	twoway (connected iany_mental_`s' year2 if region==0, msymbol(square_hollow) mcolor(black) lcolor(black) msize(medium) lpattern(dash_dot)) ///
	(connected iany_moodanx_`s' year2 if region==0, msymbol(circle) mcolor(navy) lcolor(navy) msize(medium)) ///
	(connected iany_othermental_`s' year2  if region==0, msymbol(circle) mcolor(navy*0.6) lcolor(navy*0.6) msize(medium)) , /// 
	 legend( region(lcolor(none)) size(medium) cols(2) position(6)) ylabel(0.8(0.2)2.4, nogrid labsize(medium) format(%8.1f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", labsize(medium) nogrid angle(vertical)) ytitle("Index (base=2006)") xtitle("") ///
	text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall))  text(`b3' 2049 "`a3'" , place(e) size(medsmall)) 
	
	* Save the figure 
	if "`s'" == "m" local m "b"
	else if "`s'" == "f" local m "c"
	graph save "Graph" ${results}3`m'.gph, replace
	graph export ${results}3`m'.pdf, as(pdf) name("Graph") replace	
	graph close
}		

	* Mood/anxiety visits by gender
local n=0
foreach var in iany_moodanx_f iany_moodanx_m {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.2f r(mean)
local b`n'=`a`n''+ 0.1
}	
twoway (connected iany_moodanx_f year2 if region==0, msymbol(circle) lcolor(plb2) mcolor(plb2) msize(medium) ) ///
(connected iany_moodanx_m year2 if region==0, msymbol(square) lcolor(black) mcolor(black) msize(medium)) , /// 
 legend(order(1 "Female" 2 "Male") region(lcolor(none)) size(medium)  cols(2) position(6)) ylabel(0.8(0.2)2.4, nogrid labsize(medium) format(%8.1f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid labsize(medium) angle(vertical)) ytitle("Index (base=2006)") xtitle("") ///
text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall))  
	
graph save "Graph" ${results}3d.gph, replace
graph export ${results}3d.pdf, as(pdf) name("Graph") replace
graph close

*************
* Figure 4: Prevalence and growth of suicidal behaviors 
*************
* Labels 
label var rr_suicides_10_19	"Deaths: Suicides"
label var rr_any_selfharm "ED: Self-harm"
label var rr_any_si "ED: Suicidal Ideation"
label var rr_any_si_f "Female"
label var rr_any_si_m "Male"
label var rr_any_selfharm_f "Female"
label var rr_any_selfharm_m "Male"

	* Prevalence
local n=0
foreach var in rr_suicides_10_19 rr_any_selfharm rr_any_si {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.0f r(mean)
local b`n'=`a`n''+ 45
}	
twoway (connected rr_suicides_10_19 year2 if region==0, msymbol(triangle) mcolor(plr1) lcolor(plr1) msize(medium) ) ///
 (connected rr_any_selfharm year2 if region==0, msymbol(triangle_hollow) mcolor(black*0.6) lcolor(black*0.6) msize(medium))  ///
 (connected rr_any_si year2 if region==0, msymbol(circle) lcolor(black*0.6) mcolor(black*0.6) msize(medium)) , ///
 legend( region(lcolor(none)) size(medium) cols(2) position(6)) ylabel(0(200)1000, nogrid labsize(medium) format(%8.0f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("Suicides and ED Visits per 100,000 Teens") xtitle("") text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall))  text(`b3' 2049 "`a3'" , place(e) size(medsmall))

graph save "Graph" ${results}4a.gph, replace
graph export ${results}4a.pdf, as(pdf) name("Graph") replace
graph close
 
	* Growth of Suicidal Behaviors 
label var isuicides_10_19	"Deaths: Suicides"
label var iany_selfharm "ED: Self-harm"
label var iany_si "ED: Suicidal Ideation"	
local n=0
foreach var in isuicides_10_19 iany_selfharm iany_si {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.2f r(mean)
local b`n'=`a`n''+ 0.3
}	
local b1=`b1'-0.5

twoway (connected isuicides_10_19 year2 if region==0, msymbol(triangle) mcolor(plr1) lcolor(plr1) msize(medium) ) ///
 (connected iany_selfharm year2 if region==0, msymbol(triangle_hollow) mcolor(black*0.6) lcolor(black*0.6) msize(medium))  ///
 (connected iany_si year2 if region==0, msymbol(circle) lcolor(black*0.6) mcolor(black*0.6) msize(medium)) , ///
 legend( region(lcolor(none)) size(medium) cols(2) position(6)) ylabel(1(1)7, nogrid labsize(medium) format(%8.0f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("Index (base=2006)") xtitle("") text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall))  text(`b3' 2049 "`a3'" , place(e) size(medsmall)) 
 
graph save "Graph" ${results}4b.gph, replace
graph export ${results}4b.pdf, as(pdf) name("Graph") replace
graph close
 
	* Suicidal ideation by gender 
local n=0	
foreach var in iany_si_f iany_si_m {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.2f r(mean)
local b`n'=`a`n''+ 0.3
}	

twoway (connected iany_si_f year2 if region==0, msymbol(circle) lcolor(plb2) mcolor(plb2) msize(medium) ) ///
 (connected iany_si_m year2 if region==0, msymbol(square) lcolor(black) mcolor(black) msize(medium)) , ///
 ylabel(1(1)7, nogrid format(%8.0f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("Index (base=2006)") xtitle("") text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall))  legend(order(1 "Female" 2 "Male") region(lcolor(none)) size(medium)  cols(2) position(6))
 
graph save "Graph" ${results}4c.gph, replace
graph export ${results}4c.pdf, as(pdf) name("Graph") replace
graph close
	
	* Self-harm by gender 
local n=0	
foreach var in iany_selfharm_f iany_selfharm_m {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.2f r(mean)
local b`n'=`a`n''+ 0.1
}	

twoway (connected iany_selfharm_f year2 if region==0, msymbol(circle) lcolor(plb2) mcolor(plb2) msize(medium) ) ///
 (connected iany_selfharm_m year2 if region==0, msymbol(square) lcolor(black) mcolor(black) msize(medium)) , ///
  ylabel(0.8(0.2)2.4, nogrid format(%8.1f) labsize(medium)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("Index (base=2006)") xtitle("") text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall))  legend(order(1 "Female" 2 "Male") region(lcolor(none)) size(medium)  cols(2) position(6))
 
graph save "Graph" ${results}4d.gph, replace
graph export ${results}4d.pdf, as(pdf) name("Graph") replace
graph close		
	
*************
* Figure 5: ED visits involving undetermined intent injury or self-harm 
*************
		*Self-harm vs Undetermined intent	
local n=0	
foreach var in rr_any_selfharm rr_any_selfharm_c rr_any_und rr_any_und_c {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.0f r(mean)
local b`n'=`a`n''+ 20
}	
local b2=`a2'-20

twoway (connected rr_any_selfharm year2 if region==0, msymbol(triangle_hollow) lcolor(gray) mcolor(gray) msize(medium) ) ///
(connected rr_any_selfharm_c year2 if region==0, msymbol(triangle_hollow) lpattern(dash) lcolor(gray) mcolor(gray) msize(medium) ) ///
 (connected rr_any_und year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium)) ///
  (connected rr_any_und_c year2 if region==0, msymbol(circle) lpattern(dash) lcolor(black) mcolor(black) msize(medium)), ///
  ylabel(0(100)400, nogrid labsize(medium) format(%8.0f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("ED Visits per 100,000 Teens") xtitle("") text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall)) text(`b3' 2049 "`a3'" , place(e) size(medsmall)) text(`b4' 2049 "`a4'" , place(e) size(medsmall)) legend(order(1 "ED: Self-harm"  2  "ED: Self-harm (projected)" 3 "ED: Undetermined Intent" 4 "ED: Undetermined Intent (projected)") size(medium) region(lcolor(none))  cols(2) position(6))
 
graph save "Graph" ${results}5.gph, replace
graph export ${results}5.pdf, as(pdf) name("Graph") replace
graph close

*************
* Figure 6: Observed versus projected trends in ED visits for self-harm, suicidal ideation, and mental health disorders 
*************
		*Suicidal Ideation vs Counterfactual
local n=0	
foreach var in rr_any_si rr_any_si2  {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.0f r(mean)
local b`n'=`a`n''+ 40
}	


twoway (connected rr_any_si year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) ) ///
(connected rr_any_si2 year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) lpattern(dash)) , ///
  ylabel(, nogrid labsize(medium) format(%8.0f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("ED Visits per 100,000 Teens") xtitle("") text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall))  legend(order(1 "ED: Suicidal Ideation"  2  "ED: Suicidal Ideation (projected) " ) size(medium) region(lcolor(none))  cols(1) position(6))
 
graph save "Graph" ${results}6a.gph, replace
graph export ${results}6a.pdf, as(pdf) name("Graph") replace
graph close		
	
local n=0	
foreach var in iany_si iany_si2  {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.2f r(mean)
local b`n'=`a`n''+ 0.3
}	

twoway (connected iany_si year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) ) ///
(connected iany_si2 year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) lpattern(dash)) , ///
  ylabel(, nogrid labsize(medium) format(%8.0f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("ED Visits per 100,000 Teens") xtitle("") text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall))  legend(order(1 "ED: Suicidal Ideation"  2  "ED: Suicidal Ideation (projected) " ) size(medium) region(lcolor(none))  cols(1) position(6))
 
graph save "Graph" ${results}6b.gph, replace
graph export ${results}6b.pdf, as(pdf) name("Graph") replace
graph close		
		
		
		*Mood/Anxiety vs Counterfactual
local n=0	
foreach var in rr_any_moodanx rr_any_moodanx2  {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.0f r(mean)
local b`n'=`a`n''+ 80
}	

twoway (connected rr_any_moodanx year2 if region==0,  msymbol(circle) lcolor(black) mcolor(black) msize(medium) ) ///
 (connected rr_any_moodanx2 year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) lpattern(dash)) , ///
  ylabel(, nogrid labsize(medium) format(%8.0f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("ED Visits per 100,000 Teens") xtitle("") text(`b1' 2048 "`a1'" , place(e) size(medsmall)) text(`b2' 2048 "`a2'" , place(e) size(medsmall))  legend(order(1 "ED: Mood/Anxiety"  2  "ED: Mood/Anxiety (projected) " ) size(medium) region(lcolor(none))  cols(1) position(6))
 
graph save "Graph" ${results}6c.gph, replace
graph export ${results}6c.pdf, as(pdf) name("Graph") replace
graph close			
			
local n=0	
foreach var in iany_moodanx iany_moodanx2  {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.2f r(mean)
local b`n'=`a`n''+ 0.1
}	


twoway (connected iany_moodanx year2 if region==0,  msymbol(circle) lcolor(black) mcolor(black) msize(medium) ) ///
 (connected iany_moodanx2 year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) lpattern(dash)) , ///
  ylabel(0.9(0.2)2.3, nogrid labsize(medium) format(%8.2f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("ED Visits per 100,000 Teens") xtitle("") text(`b1' 2048 "`a1'" , place(e) size(medsmall)) text(`b2' 2048 "`a2'" , place(e) size(medsmall))  legend(order(1 "ED: Mood/Anxiety"  2  "ED: Mood/Anxiety (projected) " ) size(medium) region(lcolor(none))  cols(1) position(6))
 
graph save "Graph" ${results}6d.gph, replace
graph export ${results}6d.pdf, as(pdf) name("Graph") replace
graph close		

			
	*Self-harm vs Counterfactual
local n=0	
foreach var in rr_any_selfharm rr_any_selfharm2  {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.0f r(mean)
local b`n'=`a`n''+15
}	
local b2=`b2'-30

twoway (connected rr_any_selfharm year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) ) ///
(connected rr_any_selfharm2 year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) lpattern(dash)) , ///
  ylabel(, nogrid labsize(medium) format(%8.0f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("ED Visits per 100,000 Teens") xtitle("") text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall))  legend(order(1 "ED: Self-harm"  2  "ED: Self-harm (projected) " ) size(medium) region(lcolor(none))  cols(1) position(6))
 
graph save "Graph" ${results}6e.gph, replace
graph export ${results}6e.pdf, as(pdf) name("Graph") replace
graph close		


local n=0	
foreach var in iany_selfharm iany_selfharm2  {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.2f r(mean)
local b`n'=`a`n''+0.1
}	
local b2=`a2'-0.1


twoway (connected iany_selfharm year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) ) ///
(connected iany_selfharm2 year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) lpattern(dash)) , ///
  ylabel(0.9(0.2)2.1, nogrid labsize(medium) format(%8.2f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("ED Visits per 100,000 Teens") xtitle("") text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall))  legend(order(1 "ED: Self-harm"  2  "ED: Self-harm (projected) " ) size(medium) region(lcolor(none))  cols(1) position(6))
 
graph save "Graph" ${results}6f.gph, replace
graph export ${results}6f.pdf, as(pdf) name("Graph") replace
graph close		


	* Suicidal behaviors vs counterfactual
local n=0	
foreach var in rr_behavior rr_behavior2  {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.0f r(mean)
local b`n'=`a`n''+60
}	


twoway (connected rr_behavior year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) ) ///
(connected rr_behavior2 year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) lpattern(dash)) , ///
  ylabel(400(200)1400, nogrid labsize(medium) format(%8.0f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("ED Visits per 100,000 Teens") xtitle("") text(`b1' 2048 "`a1'" , place(e) size(medsmall)) text(`b2' 2048 "`a2'" , place(e) size(medsmall))  legend(order(1 "ED: Suicidal Behaviors"  2  "ED: Suicidal Behaviors (projected) " ) size(medium) region(lcolor(none))  cols(1) position(6))
 
graph save "Graph" ${results}6g.gph, replace
graph export ${results}6g.pdf, as(pdf) name("Graph") replace
graph close		


local n=0	
foreach var in ibehavior ibehavior2  {
local n=`n'+1
sum `var' if year==2021 & region==0
local a`n': display %9.2f r(mean)
local b`n'=`a`n''+0.2
}	


twoway (connected ibehavior year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) ) ///
(connected ibehavior2 year2 if region==0, msymbol(circle) lcolor(black) mcolor(black) msize(medium) lpattern(dash)) , ///
  ylabel(0.9(0.3)3.9, nogrid labsize(medium) format(%8.2f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("ED Visits per 100,000 Teens") xtitle("") text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall))  legend(order(1 "ED: Suicidal Behaviors"  2  "ED: Suicidal Behaviors (projected) " ) size(medium) region(lcolor(none))  cols(1) position(6))
 
graph save "Graph" ${results}6h.gph, replace
graph export ${results}6h.pdf, as(pdf) name("Graph") replace
graph close		


*************
* Figure 7: Deaths by suicide and ED visits involving mental health disorders or suicidal behaviors by region 
*************
	* Completed suicides
local n=0
foreach var in northeast midwest south west {
local n=`n'+1
sum rr_suicides_10_19 if year==2021 & regionname=="`var'"
local a`n': display %9.0f r(mean)
local b`n'=`a`n''+ 0.5
}	
twoway (connected rr_suicides_10_19 year2 if regionname=="northeast", lcolor(black) mcolor(black) msize(small)) ///
(connected rr_suicides_10_19 year2 if regionname=="midwest", msymbol(triangle) lcolor(plr1) mcolor(plr1) lpattern(dash)) ///
(connected rr_suicides_10_19 year2 if regionname=="south", msymbol(square) lcolor(ply1) mcolor(ply1)  lpattern(dash_dot)) ///
(connected rr_suicides_10_19 year2 if regionname=="west", msymbol(diamond) lcolor(plg1) mcolor(plg1)  lpattern(longdash dot)), ///
 legend(order(1 "Northeast" 2 "Midwest" 3 "South" 4 "West") region(lcolor(none)) size(medium) cols(2) position(6)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ylabel(0(2)10, nogrid labsize(medium) format(%8.0f)) ytitle("Suicide Deaths per 100,000 Teens")  xtitle("")  text(10 2047 "S:`a3'", place(e) size(medsmall)) text(9.4 2046.8 "W:`a4'", place(e) size(medsmall)) text(8.8 2046.9 "M:`a2'", place(e) size(medsmall))  text(8.2 2047 "N:`a1'", place(e) size(medsmall))
graph save "Graph" ${results}7a.gph, replace
graph export ${results}7a.pdf, as(pdf) name("Graph")  replace
graph close

	* Rates of mental health disorders 
local n=0
foreach var in northeast midwest south west {
local n=`n'+1
sum rr_any_mental if year==2021 & regionname=="`var'"
local a`n': display %9.0f r(mean)
local b`n'=`a`n''+ 700
}	
twoway (connected rr_any_mental year2 if regionname=="northeast",   mcolor(black) lcolor(black) msize(small)) ///
(connected rr_any_mental year2 if regionname=="midwest",  msymbol(triangle) mcolor(plr1) lcolor(plr1) msize(small) lpattern(dash)) ///
(connected rr_any_mental year2 if regionname=="south",  msymbol(square) mcolor(ply1) lcolor(ply1) msize(small)  lpattern(dash_dot)) ///
(connected rr_any_mental year2 if regionname=="west",  msymbol(diamond) mcolor(plg1) lcolor(plg1) msize(small)  lpattern(longdash dot)), ///
 legend(order(1 "Northeast" 2 "Midwest" 3 "South" 4 "West") region(lcolor(none)) size(medium)  cols(2) position(6)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ylabel(0(1000)7000, nogrid labsize(medium) format(%8.0f))  ytitle("ED Visits per 100,000 Teens", size(medsmall)) xtitle("")  text(7000 2047 "M:`a2'", place(e) size(medsmall)) text(6600 2047 "N:`a1'", place(e) size(medsmall)) text(6200 2047 "S:`a3'", place(e) size(medsmall))  text(5800 2047 "W:`a4'", place(e) size(medsmall))
graph save "Graph" ${results}7b.gph, replace
graph export ${results}7b.pdf, as(pdf) name("Graph")  replace
graph close
		
	* Rates of suicidal ideation by region
local n=0
foreach var in northeast midwest south west {
local n=`n'+1
sum rr_any_si if year==2021 & regionname=="`var'"
local a`n': display %9.0f r(mean)
local b`n'=`a`n''+ 50
}
	
twoway (connected rr_any_si year2 if regionname=="northeast",   mcolor(black) lcolor(black) msize(small)) ///
(connected rr_any_si year2 if regionname=="midwest",  msymbol(triangle) mcolor(plr1) lcolor(plr1) msize(small) lpattern(dash)) ///
(connected rr_any_si year2 if regionname=="south",  msymbol(square) mcolor(ply1) lcolor(ply1) msize(small)  lpattern(dash_dot)) ///
(connected rr_any_si year2 if regionname=="west",  msymbol(diamond) mcolor(plg1) lcolor(plg1) msize(small)  lpattern(longdash dot)), ///
legend(order(1 "Northeast" 2 "Midwest" 3 "South" 4 "West") region(lcolor(none)) size(medium)  cols(2) position(6)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ylabel(0(250)1500, nogrid labsize(medium) format(%8.0f)) ytitle("ED Visits per 100,000 Teens", size(medsmall)) xtitle("")   text(1500 2044 "M:`a2'", place(e) size(medsmall)) text(1430 2044 "N:`a1'", place(e) size(medsmall)) text(1350 2044 "S:`a3'", place(e) size(medsmall))  text(1270 2043.8 "W:`a4'", place(e) size(medsmall))
graph save "Graph" ${results}7c.gph, replace
graph export ${results}7c.pdf, as(pdf) name("Graph")  replace
graph close
		
	* Rates of self-harm by region
local n=0
foreach var in northeast midwest south west {
local n=`n'+1
sum rr_any_selfharm if year==2021 & regionname=="`var'"
local a`n': display %9.0f r(mean)
local b`n'=`a`n''+ 50
}
twoway (connected rr_any_selfharm year2 if regionname=="northeast",   mcolor(black) lcolor(black) msize(small)) ///
(connected rr_any_selfharm year2 if regionname=="midwest",  msymbol(triangle) mcolor(plr1) lcolor(plr1) msize(small) lpattern(dash)) ///
(connected rr_any_selfharm year2 if regionname=="south",  msymbol(square) mcolor(ply1) lcolor(ply1) msize(small)  lpattern(dash_dot)) ///
(connected rr_any_selfharm year2 if regionname=="west",  msymbol(diamond) mcolor(plg1) lcolor(plg1) msize(small)  lpattern(longdash dot)), ///
legend(order(1 "Northeast" 2 "Midwest" 3 "South" 4 "West") region(lcolor(none))  size(medium) cols(2) position(6)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ylabel(0(100)600, nogrid labsize(medium) format(%8.0f)) ytitle("ED Visits per 100,000 Teens") xtitle("")   text(600 2044 "M:`a2'", place(e) size(medsmall)) text(570 2043.8 "W:`a4'", place(e) size(medsmall)) text(540 2044 "S:`a3'", place(e) size(medsmall))  text(510 2044 "N:`a1'", place(e) size(medsmall))
graph save "Graph" ${results}7d.gph, replace
graph export ${results}7d.pdf, as(pdf) name("Graph")  replace
graph close


**************************
* APPENDIX
*************************
*************
* Figure A1:ED visits involving any mental health disorder, mood, or anxiety
*************	
	* Rate of Mood vs Anxiety vs All Mental 
label var rr_any_mental	"ED: Any Mental Health Disorder"
label var rr_any_mood "ED: Any Mood Disorder"
label var rr_any_anxiety "ED: Any Anxiety Disorder"
	
local n=0
foreach var in rr_any_mental rr_any_mood rr_any_anxiety  {
	local n=`n'+1
	sum `var' if year==2021 & region==0
	local a`n': display %9.0f r(mean)
	local b`n'=`a`n''+ 400
}
local b3=`a3'-400

twoway (connected rr_any_mental year2 if region==0, msymbol(square_hollow) mcolor(black) lcolor(black) msize(medium) lpattern(dash_dot)) ///
(connected rr_any_mood year2 if region==0, msymbol(circle_hollow) mcolor(black) lcolor(black) msize(medium)) ///
(connected rr_any_anxiety year2 if region==0, msymbol(circle) mcolor(black) lcolor(black) msize(medium)) , /// 
legend( region(lcolor(none)) size(medium) cols(2) position(6)) ylabel(0(1000)5000, nogrid labsize(medium) format(%8.0f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("ER Visits per 100,000 Teens") xtitle("") text(`b1' 2047 "`a1'" , place(e) size(medsmall)) text(`b2' 2047 "`a2'" , place(e) size(medsmall))  text(`b3' 2047 "`a3'" , place(e) size(medsmall)) 
graph save "Graph" ${results}A1a.gph, replace
graph export ${results}A1a.pdf, as(pdf) name("Graph")  replace
graph close
	
	* Growth of Mood vs Anxiety vs All Mental 
label var iany_mental	"ED: Any Mental Health Disorder"
label var iany_mood "ED: Any Mood Disorder"
label var iany_anxiety "ED: Any Anxiety Disorder"
	
local n=0
foreach var in iany_mental iany_mood iany_anxiety  {
	local n=`n'+1
	sum `var' if year==2021 & region==0
	local a`n': display %9.2f r(mean)
	local b`n'=`a`n''+ 0.2
}	

twoway (connected iany_mental year2 if region==0, msymbol(square_hollow) mcolor(black) lcolor(black) msize(medium) lpattern(dash_dot)) ///
(connected iany_mood year2 if region==0, msymbol(circle_hollow) mcolor(black) lcolor(black) msize(medium)) ///
(connected iany_anxiety year2 if region==0, msymbol(circle) mcolor(black) lcolor(black) msize(medium)) , /// 
legend( region(lcolor(none)) size(medium) cols(2) position(6)) ylabel(0.8(0.2)4, nogrid labsize(medium) format(%8.1f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid angle(vertical) labsize(medium)) ytitle("Index (base=2006)") xtitle("") text(`b1' 2049 "`a1'" , place(e) size(medsmall)) text(`b2' 2049 "`a2'" , place(e) size(medsmall))  text(`b3' 2049 "`a3'" , place(e) size(medsmall)) 
graph save "Graph" ${results}A1b.gph, replace
graph export ${results}A1b.pdf, as(pdf) name("Graph")  replace
graph close


*************
* Figure A2: Growth of ED visits involving mental health disorders by region and urban-rural 
*************
local n=0
foreach var in northeast midwest south west rural urban {
	local n=`n'+1
	sum iany_mental if year==2021 & regionname=="`var'"
	local a`n': display %9.2f r(mean)
	local b`n'=`a`n''+0.2

	sum iany_moodanx if year==2021 & regionname=="`var'"
	local c`n': display %9.2f r(mean)
	local d`n'=`c`n''+0.2

	sum iany_othermental if year==2021 & regionname=="`var'"
	local e`n': display %9.2f r(mean)
	local f`n'=`e`n''+0.2
	
}	

local n=0 
foreach var in northeast  midwest south west rural urban {
	local n=`n'+1
	local file1="a" 
	local file2="b" 
	local file3="c" 
	local file4="d" 
	local file5="e" 
	local file6="f" 	
	
	twoway (connected iany_mental year2 if regionname=="`var'", msymbol(square_hollow) mcolor(black) lcolor(black) msize(medium) lpattern(dash_dot)) ///
	(connected iany_moodanx year2 if regionname=="`var'", msymbol(circle) mcolor(navy) lcolor(navy) msize(medium)) ///
	(connected iany_othermental year2 if regionname=="`var'", msymbol(circle) mcolor(navy*0.6) lcolor(navy*0.6) msize(medium)) , /// 
	legend( region(lcolor(none)) size(medium) cols(2) position(6)) ylabel(0.8(0.2)2.4, nogrid labsize(medium) format(%8.1f)) xlabel(2006 "2006" 2009 "2007" 2012 "2008" 2015 "2009" 2018 "2010" 2021 "2011" 2024 "2012" 2027 "2013" 2030 "2014" 2033 "2015" 2036 "2016" 2039 "2017" 2042 "2018" 2045 "2019" 2048 "2020" 2051 "2021", nogrid  angle(vertical) labsize(medium)) ytitle("Index (base=2006)") xtitle("")  text(`b`n'' 2049 "`a`n''" , place(e) size(medsmall)) text(`d`n'' 2049 "`c`n''" , place(e) size(medsmall)) text(`f`n'' 2049 "`e`n''" , place(e) size(medsmall))
	graph save "Graph" ${results}A2`file`n''.gph, replace
	graph export ${results}A2`file`n''.pdf, as(pdf) name("Graph")  replace
	graph close	
}
	
